var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0}),
    (o.instantiate = o.prefabs = void 0),
    (o.prefabs = {}),
    (o.instantiate = function (t) {
        var e = o.prefabs[t];
        if (null == e) throw Error("[Prefabs] prefab not load " + t);
        return cc.instantiate(e);
    });
var a = cc._decorator,
    i = a.ccclass,
    s = a.property,
    c = (function (t) {
        function e() {
            var e = (null !== t && t.apply(this, arguments)) || this;
            return (e.prefabs = []), e;
        }
        return (
            n(e, t),
            (e.prototype.onLoad = function () {
                (this.s = {}), this.add(this.prefabs), (this.enabled = !1);
            }),
            (e.prototype.add = function (t) {
                for (var e = 0, o = t; e < o.length; e++) {
                    var n = o[e];
                    n &&
                        (this.s[n.data.name]
                            ? console.error("重复名字的 prefab：" + n.data.name)
                            : (this.s[n.data.name] = n));
                }
            }),
            (e.prototype.has = function (t) {
                return !!this.s[t];
            }),
            (e.prototype.instantiate = function (t) {
                t = t.replace(/^.+\//, "");
                var e = this.s[t];
                return e ? cc.instantiate(e) : (console.error("木有Prefab：" + t), null);
            }),
            r([s([cc.Prefab])], e.prototype, "prefabs", void 0),
            (e = r([i], e))
        );
    })(cc.Component);
o.default = c;
